//====================================================================================================
//									报表工具
//====================================================================================================
RptUtils = {};
/**
 * js/css文件加载状态
 */
RptUtils._load_status_ = {};
/**
 * 加载css、js文件
 */
RptUtils.load_jscss = function(javascripts,styles,callback){
	if(styles){
		var csses = [];
		for (var index = 0; index < styles.length; index++) {
			var css = styles[index];
			if(!RptUtils._load_status_[css]){
				csses.push(css);
				RptUtils._load_status_[css] = true;
			}
		}
		if(csses.length > 0){
			cmp.asyncLoad.css(csses);
		}
	}
	if(javascripts){
		var jses = [];
		for (var index = 0; index < javascripts.length; index++) {
			var js = javascripts[index];
			if(!RptUtils._load_status_[js]){
				jses.push(js);
				RptUtils._load_status_[js] = true;
			}
		}
		if(jses.length > 0){
			cmp.asyncLoad.js(jses,function(){
				callback();
			});
		}else{
			callback();
		}
	}else{
		callback();
	}
}

RptUtils.getFilterValue = function(fieldValues,userConditions,headFieldMaps,filterFieldMaps){
	var filterValue = {};
	//TODO 高级模式待定
	var userFieldValues = {};
	for(var i = 0, len1 = userConditions.length; i < len1; i++){
		var cond = userConditions[i] , fieldKey = cond.aliasTableName + "_" + cond.fieldName;
		if(cond.operation == "GreatEqual" || cond.operation == "Greater" || cond.operation == "Less" || cond.operation == "LessEqual" ){
			var value = (userFieldValues[fieldKey] == undefined) ? ["",""] : userFieldValues[fieldKey];
			if(cond.operation == "GreatEqual" || cond.operation == "Greater"){
				value[0] = cond.fieldValue;
			}else{
				value[1] = cond.fieldValue;
			}
			userFieldValues[fieldKey] = value;
		}else{
			userFieldValues[fieldKey] = cond.fieldValue;
		}
	}
	for(var i = 0, len1 = filterFieldMaps.length; i < len1; i++){
		var fieldMap = filterFieldMaps[i] , fieldKey = fieldMap.currentFieldATName + "_" + fieldMap.currentFieldName;
		if(undefined != userFieldValues[fieldKey]){
			var toFieldKey = fieldMap.toFieldATName + "." + fieldMap.toFieldName;
			filterValue[toFieldKey] = userFieldValues[fieldKey];
		}
	}
	
	//分组项
	for(var i = 0, len1 = headFieldMaps.length; i < len1; i++){
		var fieldMap = headFieldMaps[i] , fieldKey = fieldMap.currentFieldATName + "_" + fieldMap.currentFieldName;
		if(undefined != fieldValues[fieldKey]){
			var toFieldKey = fieldMap.toFieldATName + "." + fieldMap.toFieldName;
			var value = fieldValues[fieldKey];
			if(fieldMap.properties.fieldComType == "date"){
				filterValue[toFieldKey] = getDateValue(value,fieldMap.properties.groupType);
			}else if(fieldMap.properties.fieldComType == "datetime"){
				filterValue[toFieldKey] = getDatetimeValue(value,fieldMap.properties.groupType);
			}else if(fieldMap.properties.fieldComType == "text" && fieldMap.properties.dbType == "DECIMAL"){
				filterValue[toFieldKey] = [value,value];
			}else if(fieldMap.properties.fieldComType == "member"){
				filterValue[toFieldKey] = "Member|"+value;
			}else if(fieldMap.properties.fieldComType == "account"){
				filterValue[toFieldKey] = "Account|"+value;
			}else if(fieldMap.properties.fieldComType == "department"){
				filterValue[toFieldKey] = "Department|"+value;
			}else if(fieldMap.properties.fieldComType == "post"){
				filterValue[toFieldKey] = "Post|"+value;
			}else if(fieldMap.properties.fieldComType == "level"){
				filterValue[toFieldKey] = "Level|"+value;
			}else{
				filterValue[toFieldKey] = value;
			}
		}
	}
	return filterValue;
}
/**
 * 过滤条件使用的插件
 */
;~(function($){
    /**
     * 只能输入18位并且5位小数点的插件
     */
    function rptNumOnly($element){
        var value = $element.val();
        if(value.length>0){
            //替换非数字
            if(isNaN(value) || !/^[-]?\d+(\.\d+)?$/.test(value)){
                var dotIndex = value.indexOf(".");
                value = value.replace(/^[.]|[^0123456789.-]+|[.-]{2,}/g,"");
                if(value != "-" && value != "+" && isNaN(value)){
                    value = value.replace(/[.-]+/g,"");
                }
            }
            //去除多余的0
			value = value.replace(/^(0+)/g,"0");
			value = value.replace(/^0(\d+)(\.\d+)?/g,"$1$2");
            // 切割只剩限制的数据
            var dotIndex = value.indexOf(".");
            var start = 0,end = 0;
            if(dotIndex > -1){
                start = dotIndex - 18;//Long.MAX_VALUE = 9223 37203 68547 75807[19]
                if(start < 0){
                    start = 0;
                }
                end = dotIndex + 6
            }else{
                start = 0;
                end = 18;
            }
            value = value.substr(start,end);
            if($element.val()!=value){
                $element.val(value);
            }
        }
        $element = null;
    }

    /**
     * 注册为jQuery插件
     */
    $.fn.rptNumOnly = function(){
		this.on("input keyup",function(){
			rptNumOnly($(this));
		}).on("blur",function(){
			rptNumOnly($(this));
		});

	}

})(Zepto);


//====================================================================================================
//									首页
//====================================================================================================
var RptIndex = {};
/**
 * 报表移动端首页
 */
RptIndex.init =function(){
	cmp.dialog.loading(cmp.i18n("report.common.loading"));//"数据加载中.....");
	var params = RptIndex._getParams_();
	RptIndex.designId = params.designId;
	RptIndex.isPreview =  ("true" == params.preview);
	if(RptIndex.isPreview){
		clickOrTap = "click";//预览使用click
	}
	/**
	 * 读取配置信息
	 */
	params.cmp = cmp.platform.CMPShell;
	rptApi.getReportConfig({},params, {
		success : function(result) {
			if (result.success) {
				RptIndex._loadConfigCb_(result.data);
			} else {
				RptCondtions.alert(result.msg);
			}
		},
		error : function(error) {
			var cmpHandled = cmp.errorHandler(error);
			if (!cmpHandled) {
				if (error.message) {
					RptCondtions.alert(error.message);
				} else {
					RptCondtions.alert(cmp.toJSON(error));
				}
			}
		}
	});
	var wh = $(window).height();
	$(".rptcon-main").css("max-height",(wh - 44 -42) + "px");

}
/**
 * 配置信息加载成功后回调
 */
RptIndex._loadConfigCb_ = function(data){
	setTimeout(function(){
		for (var int = 0; int < data.csses.length; int++) {
			data.csses[int] = tplPath + data.csses[int];
		}
		cmp.asyncLoad.css(data.csses);
		for (var int = 0; int < data.jses.length; int++) {
			data.jses[int] = tplPath + data.jses[int];
		}
		cmp.asyncLoad.js(data.jses,function(){
			RptIndex._loadData_();//渲染数据
			cmp.dialog.loading(false);
		});
	},0);
	RptIndex.data = data;
	//设置标题
	document.title = data.title
	var fields = data.filterFields;
	if(fields !== undefined && fields.length > 0){
		$(".rpt-index-body").css("top","44px");
		$("#user-condtions").css("visibility","visible");
		RptIndex._condition = new RptCondtions({
			"headselector":"#user-condtions",
			"conselector":"#rptcon-area",
			"fields":fields,
			"doQuery":function(conditions){
				RptIndex._reloadloadData_(conditions);
			}
		});
	}
}
/** 获取URL的查询参数 */
RptIndex._getParams_=function(){
	var url = window.location.search,
	reg_url = /^\?([\w\W]+)$/,
	reg_para = /([^&=]+)=([\w\W]*?)(&|$|#)/g,
	arr_url = reg_url.exec(url),
	params = {};
	if (arr_url && arr_url[1]) {
		var str_para = arr_url[1], result;
		while ((result = reg_para.exec(str_para)) != null) {
			params[result[1]] = result[2];
		}
	}
	var cmpparams = cmp.href.getParam();
	if(cmpparams){
		params = $.extend(params,cmpparams)
	}
    return params;
}

/**
 * 渲染数据
 */
RptIndex._loadData_ = function(){
	RptCondtions.handler = new DataHandler({
		"container":"#table-warp",
		"userConditions":(RptIndex._condition ? RptIndex._condition.getCondition() : []),
		"isPreview":RptIndex.isPreview,
		"designId":RptIndex.designId
	});
}
/**
 * 重新渲染数据
 */
RptIndex._reloadloadData_ = function(conditions){
	RptCondtions.handler.reload(conditions);
}


//====================================================================================================
//													筛选条件
//====================================================================================================
/**
 * 筛选条件
 * @param {*} options 
 */
function RptCondtions(options){
	this.$dom = $(options.headselector);
	this.$conselector = $(options.conselector);
	this.options = options;
	RptCondtions._init_tpl_();//避免国际化问题，单独初始化
	//初始化头部
	this._init_head_();
	this._init_events_();
	this._init_dom_(true);
}
/**
 * 获取用户条件
 */
RptCondtions.prototype.getCondition = function(){
	var fields = this.options.fields,
		conditions = []; //条件;
	$items = this.$conselector.find(".rptcon-component");
	for (var rowi = 0, rowlen = $items.length; rowi < rowlen; rowi++) {
		var $item = $items.eq(rowi);
			fieldIndex = $item.attr("field-index"),
			field = fields[fieldIndex];
		if ($item.hasClass("empty-value")) { //选择空值处理
			conditions.push({
				"leftChar": "(",
				"aliasTableName": field.aliasTableName,
				"fieldName": field.name,
				"operation": "Equal",
				"fieldValue": "",
				"rightChar": ")",
				"rowOperation": "and"
			});
			continue; //不进行下边的操作
		}
		var $input = $item.find("input.rptcon-cpt-input-value")
		switch (field.fieldComType) {
			case "text": //文本
			case "textarea": //文本域
			{
				if ("VARCHAR" === field.dbType) { // 文本类型
					var val = $input.val();
					if (val === "") {
						continue;
					}
					conditions.push({
						"leftChar": "(",
						"aliasTableName": field.aliasTableName,
						"fieldName": field.name,
						"operation": "Like",
						"fieldValue": val,
						"rightChar": ")",
						"rowOperation": "and"
					});
				} else {
					for (var numi = 0; numi < 2; numi++) {
						var val = $input.eq(numi).val();
						if (val !== "") {
							conditions.push({
								"leftChar": "(",
								"aliasTableName": field.aliasTableName,
								"fieldName": field.name,
								"operation": (numi === 0 ? "GreatEqual" : "LessEqual"),
								"fieldValue": val,
								"rightChar": ")",
								"rowOperation": "and"
							});
						}
					}
					var val1 = $input.eq(0).val();
					var val2 = $input.eq(1).val();
					if(val1  !== ""&& val2 !== ""){
						if(val1 > val2){////"起始值不能大于截止值"
							RptCondtions.tips(cmp.i18n("report.condition.startnotgtend"));
							return false;
						}
					}
				}
				break;
			}
			case "radio": //单选
			case "select": //下拉
			case "customenum": //自定义枚举
			case "imageenum": //图片枚举
			{
				var $selected = $item.find(".rptcon-cpt-items .item-selected");
				if($selected.length === 0){
					continue;
				}
				var vars = [],
					isIncludeEmpty = false,
					isIncludeEnum = false;
				for (var index = 0; index < $selected.length; index++) {
					var enumIndex = $selected.eq(index).attr("enum-index");
					if("empty" === enumIndex){
						isIncludeEmpty = true;
					}else{
						isIncludeEnum = true;
						vars.push(field.enumItems[enumIndex]);
					}
				}
				if (isIncludeEmpty) {
					conditions.push({
						"leftChar": "(",
						"aliasTableName": field.aliasTableName,
						"fieldName": field.name,
						"operation": "Equal",
						"fieldValue": "",
						"rightChar": (isIncludeEnum ? "" : ")"),
						"rowOperation": (isIncludeEnum ? "or" : "and")
					});
				}
				if (isIncludeEnum) {
					conditions.push({
						"leftChar": (isIncludeEmpty ? "" : "("),
						"aliasTableName": field.aliasTableName,
						"fieldName": field.name,
						"operation": "Equal",
						"fieldValue": vars,
						"rightChar": ")",
						"rowOperation": "and"
					});
				}
				break;
			}
			case "multimember": //选多人
			case "multiaccount": //多单位
			case "multidepartment": //多部门
			case "multipost": //多岗位
			case "multilevel": //多职务
			case "member": //选人
			case "account": //单位
			case "department": //部门
			case "post": //岗位
			case "level": //职务
			{
				var val = $input.val();
				if (val === "") {
					continue;
				}
				conditions.push({
					"leftChar": "(",
					"aliasTableName": field.aliasTableName,
					"fieldName": field.name,
					"operation": "Like",
					"fieldValue": (function(field){
						var isMultiOrg = RptCondtions._isMultiOrg_(field.fieldComType);
						var rs = [];
						for (var index = 0; index < field._fbdata_.length; index++) {
							var org = field._fbdata_[index];
							rs.push(org.type + "|" + org.id);
						}
						return isMultiOrg ? rs.join(",") : rs;
					})(field),
					"rightChar": ")",
					"rowOperation": "and"
				});
				break;
			}
			case "checkbox": //复选
			{
				var $selected = $item.find(".rptcon-cpt-items .item-selected");
				if($selected.length === 0){
					continue;
				}
				var vars = [];
				for (var index = 0; index < $selected.length; index++) {
					var enumIndex = $selected.eq(index).attr("enum-index");
					if("1" === enumIndex){
						vars.push("0");
					}else{
						vars.push("1");
					}
				}
				conditions.push({
					"leftChar": "(",
					"aliasTableName": field.aliasTableName,
					"fieldName": field.name,
					"operation": "Equal",
					"fieldValue": vars.join(","),
					"rightChar": ")",
					"rowOperation": "and"
				});
				break;
			}
			case "date": //日期
			case "datetime": //日期时间
			{
				for (var numi = 0; numi < 2; numi++) {
					var val = $input.eq(numi).val();
					if (val !== "") {
						conditions.push({
							"leftChar": "(",
							"aliasTableName": field.aliasTableName,
							"fieldName": field.name,
							"operation": (numi === 0 ? "GreatEqual" : "LessEqual"),
							"fieldValue": val,
							"rightChar": ")",
							"rowOperation": "and"
						});
					}
				}
				break;
			}
			case "project": //项目
				break;
		}
	}
	return conditions;
}
/**
 * 初始化头部
 */
RptCondtions.prototype._init_head_ =function(){
	var  fields = this.options.fields,
		 flength = fields.length,
		 $rptconicons = this.$dom.find(".rptcon-ico");
	// 初始化标签
	for (var int = 0; int < flength && int < 3; int++) {
		$rptconicons.eq(int).find(".label").text(fields[int].aliasDisplay);
	}
	if(flength == 4){
		$rptconicons.eq(3).find(".label").text(fields[3].aliasDisplay);
	}else if(flength > 4){
		$rptconicons.eq(3).find(".label").text(cmp.i18n("report.common.more"));//"更多");
	}else{
		var i = 4;
		while (i > flength) {
			$rptconicons.eq(i -1).hide();
			i--;
		}
	}
	// 点击空白地方关闭
	$(".rpt-barea-bg").on(clickOrTap,function(event){
		$(".rptcon-area").css("display","none");
		$rptconicons.removeClass("opend");
	});
	// 点击上边的按钮
	$rptconicons.on(clickOrTap,function(event){
		var $this = $(this);
		if($this.hasClass("opend")){
			$(".rptcon-area").css("display","none");
		}else{
			var $content = $("#rpt-con-area-" + $this.attr("targetid"));
			$(".rptcon-area").css("display","block");
			$content.show().siblings().hide();
		}
		$this.toggleClass("opend").siblings().removeClass("opend");
	});
}
/**
 * 初始化dom
 */
RptCondtions.prototype._init_dom_ = function(initDefaultValue){
	var fields = this.options.fields,
		tpls = RptCondtions.tpls;
	for (var int = 0,flength = fields.length; int < flength; int++) {
		var field = fields[int],
			html = "",
			showTitle = (int > 2 && flength > 4),
			rdo = { 
				"showTitle":showTitle , 
				"fieldName":field.aliasDisplay,
				"fieldIndex":int
			};
		switch (field.fieldComType) {
            case "text": //文本
            case "textarea": //文本域
        	{
				var defaultVal = ["",""],showX = false;
				if ("VARCHAR" === field.dbType) { // 文本类型
					category = "varchar";
					defaultVal = "";
				}
				if(initDefaultValue && field.defaultValue){
					defaultVal = field.defaultValue.value;
					showX = true;
				}
				rdo.showX = showX;
				rdo.value = defaultVal;
            	if(field.dbType == "VARCHAR"){
            		html = tpls.textTpl.render(rdo);
            	}else{
            		html = tpls.numTpl.render(rdo);
            	}
            	break;
        	}
            case "checkbox": //复选
        	{
            	rdo.enumItems = [{
            		"id":"1",
            		"value":"1",
            		"name":cmp.i18n("report.condition.checked")//"勾选"
            	},{
            		"id":"0",
            		"value":"0",
            		"name":cmp.i18n("report.condition.unchecked")//"未勾选"
				}];
				var selectedItem = [];
				if(initDefaultValue && field.defaultValue){
					var dv = field.defaultValue.dataValue;
					if(dv.indexOf("1") > -1){
						selectedItem.push(0);
					}
					if(dv.indexOf("0") > -1){
						selectedItem.push(1);
					}
				}
				rdo.selectedItem = selectedItem;
				rdo.useEmpty = false;
            	html = tpls.enumTpl.render(rdo);
            	break;
        	}
            case "radio": //单选
            case "select": //下拉
            case "customenum": //自定义枚举
            case "imageenum": //图片枚举
        	{	
				rdo.useEmpty = true;
				rdo.enumItems = field.enumItems;
				var selectedItem = [];
				if(initDefaultValue && field.defaultValue){
					var dv = field.defaultValue.dataValue;
					for (var itemIndex = 0,itemLength = rdo.enumItems.length; itemIndex < itemLength; itemIndex++) {
						var enumItem = rdo.enumItems[itemIndex];
						if(dv.indexOf(enumItem.value + "|" + enumItem.id) > -1){
							selectedItem.push(itemIndex);
						}
					}
					rdo.defEmpty = (dv.indexOf("empty") > -1);
				}
				rdo.selectedItem = selectedItem;
            	html = tpls.enumTpl.render(rdo);
            	break;
        	}
            case "multimember": //选多人
            case "multiaccount": //多单位
            case "multidepartment": //多部门
            case "multipost": //多岗位
            case "multilevel": //多职务
            case "member": //选人
            case "account": //单位
            case "department": //部门
            case "post": //岗位
            case "level": //职务
            {
				var val = "",showX = false;
				if(initDefaultValue && field.defaultValue){
					var dvs = field.defaultValue.dataValue;
					var svs = field.defaultValue.value;
					var _fbdata_ = [];
					for (var dvsindex = 0,dvsLength = dvs.length; dvsindex < dvsLength; dvsindex++) {
						var dv = dvs[dvsindex].split("|");
						_fbdata_.push({
							"id":dv[1],
							"name":svs[dvsindex],
							"type":dv[0]
						});
					}
					field._fbdata_ = _fbdata_;
					val = field.defaultValue.value.join("、");
					if(dvsLength > 0){
						showX = true;
					}
				}
				rdo.showX = showX;
				rdo.value = val;
				html = tpls.orgTpl.render(rdo);
            	break;
            }
            case "date": //日期
            case "datetime": //日期时间
        	{
				var defaultVal = ["",""];
				if(initDefaultValue && field.defaultValue){
					if("manually" === field.defaultValue.mode){
						defaultVal = field.defaultValue.value;
					}else{
						// 获取默认
						defaultVal = RptCondtions._change_date_type(field.defaultValue.value[0],field.fieldComType);
						rdo.defaultSelected = field.defaultValue.value[0];
					}
				}
				rdo.value = defaultVal;
				html = tpls.dateTpl.render(rdo);
            	break;
			}
			case "project": //项目
			default://默认不支持
				continue;
        }
		if(!showTitle){
			this.$conselector.find("#rpt-con-area-" + (int + 1)).append(html);
		}else{
			this.$conselector.find("#rpt-con-area-4").append(html);
		}
	}
	this.$conselector.find(".rpt-num-only").each(function(){
		$(this).rptNumOnly();
	}); 
}

/**
 * 初始化事件
 */
RptCondtions.prototype._init_events_ = function(){
	var self = this,
		fields = self.options.fields;
	this.$conselector.on(clickOrTap,".rptcon-select .rptcon-cpt-item",function(){//枚举
		$(this).toggleClass("item-selected");
	}).on(clickOrTap,".rptcon-select .cmp-icon,.rptcon-datetime .cmp-icon",function(){// 展开收起
		var $cmpIco = $(this);
		$cmpIco.parent().toggleClass("opend").toggleClass("closed");
		$cmpIco.parent().siblings(".rptcon-cpt-content").find(".rptcon-cpt-items").toggleClass("rptcon-limit-h");
	}).on(clickOrTap,".rptcon-component .empty-btn",function(){// 空值
		$(this).parents(".rptcon-component").toggleClass("empty-value");
	}).on("input",".rptcon-component .rptcon-cpt-input-value",function(event){//x
		if(this.value !== ""){
			$(this).siblings(".rptcon-cpt-clear").removeClass("rptcon-hide");//显示X;
		}else{
			$(this).siblings(".rptcon-cpt-clear").addClass("rptcon-hide");//显示X;
		}
	}).on(clickOrTap,".rptcon-component .rptcon-cpt-clear",function(event){//x
		var $clearBtn = $(this),
			$rptComponent = $clearBtn.parents(".rptcon-component"),
			fieldIndex = $rptComponent.attr("field-index"),
			field = fields[fieldIndex],
			fieldComType = fields[fieldIndex].fieldComType;
		$clearBtn.siblings("input").val("");
		$clearBtn.addClass("rptcon-hide");
		//组织机构
		if(RptCondtions._isOrg_(fieldComType)){
			$clearBtn.siblings(".rptcon-cpt-arrow").removeClass("rptcon-hide");//显示>;
			field._fbdata_ = [];
		}else if(fieldComType === "date" || fieldComType === "datetime"){
			$rptComponent.find(".rptcon-cpt-item").removeClass("item-selected");
		}
		event.stopPropagation();
	}).on(clickOrTap,".rptcon-org .rptcon-cpt-input-value",function(event){//组织机构控件
		var $target = $(event.srcElement || event.target);
		if($target.hasClass("rptcon-cpt-clear")){
			return;
		}
		var $input = $(this),//.find(".rptcon-cpt-input-value"),
			$rptComponent = $input.parents(".rptcon-component"),
			fieldIndex = $rptComponent.attr("field-index"),
			field = fields[fieldIndex],
			fieldComType = fields[fieldIndex].fieldComType;
		if($rptComponent.hasClass("empty-value")){
			return;
		}
		RptCondtions._select_org_({
			"fbdata":field._fbdata_ ? field._fbdata_ : [],
			"type":fieldComType
		},function(rs){
			field._fbdata_ = rs;
			var names = [];
			for (var index = 0; index < rs.length; index++) {
				var org = rs[index];
				names.push(org.name);
			}
			$input.val(names.join("、"));
			if(names.length > 0){
				$input.siblings(".rptcon-cpt-clear").removeClass("rptcon-hide").siblings(".rptcon-cpt-arrow").addClass("rptcon-hide");;//显示x;
			}else{
				$input.siblings(".rptcon-cpt-clear").addClass("rptcon-hide").siblings(".rptcon-cpt-arrow").removeClass("rptcon-hide");//显示x;
			}
		});
	}).on(clickOrTap,".rptcon-datetime .rptcon-cpt-input-value",function(event){//选择日期
		var $target = $(event.srcElement || event.target);
		if($target.hasClass("rptcon-cpt-clear")){
			return;
		}
		var $input = $(this),//.find(".rptcon-cpt-input-value"),
			$rptComponent = $input.parents(".rptcon-component"),
			fieldIndex = $rptComponent.attr("field-index"),
			fieldComType = fields[fieldIndex].fieldComType,
			options = { type : fieldComType },
			currentDate = $input.val();
		if($rptComponent.hasClass("empty-value")){
			return;
		}
		if (currentDate.length > 0) {
			options.value = currentDate;
		}
		RptCondtions._select_date_(options,function(rs){
			var start = null,end = null;
			if($input.hasClass("first-input")){
				start = rs;
				end = $rptComponent.find(".second-input").val();
			}else{
				start = $rptComponent.find(".first-input").val();
				end = rs;
			}
			var isOk = true;
			if(start !== "" && end !== ""){
				if("date" === fieldComType){
					start = RptCondtions.parseDate(start).getTime();
					end = RptCondtions.parseDate(end).getTime();
				}else{
					start = RptCondtions.parseDateTime(start + ":00").getTime();
					end = RptCondtions.parseDateTime(end + ":00").getTime();
				}
				if(start > end){
					isOk = false;
				}
			}
			if(isOk){
				$input.val(rs);
				$input.siblings(".rptcon-cpt-clear").removeClass("rptcon-hide");//显示x
				$rptComponent.find(".rptcon-cpt-item").removeClass("item-selected");
			}else{
				RptCondtions.tips(cmp.i18n("report.condition.startdategtenddate"));//"开始时间不能大于结束时间");
			}
		});
	}).on(clickOrTap,".rptcon-datetime .rptcon-cpt-item",function(){//日期快捷
		var $rptconItem = $(this),
			dateType = $rptconItem.attr("date-type");
		if(dateType != "empty"){
			var $rptComponent = $rptconItem.parents(".rptcon-component"),
				fieldIndex = $rptComponent.attr("field-index"),
				dateArray = RptCondtions._change_date_type(dateType,fields[fieldIndex].fieldComType),
				$inputValue = $rptComponent.find(".rptcon-cpt-input-value");
			$inputValue.eq(0).val(dateArray[0]).siblings(".rptcon-cpt-clear").removeClass("rptcon-hide");//显示x;
			$inputValue.eq(1).val(dateArray[1]).siblings(".rptcon-cpt-clear").removeClass("rptcon-hide");//显示x;
			$rptComponent.removeClass("empty-value");
		}else{
			$rptconItem.parents(".rptcon-component").toggleClass("empty-value");
		}
		$rptconItem.toggleClass("item-selected").siblings().removeClass("item-selected");
	}).on(clickOrTap,".rptcon-reset",function(){
		self.$conselector.find("#rpt-con-area-1").html("");
		self.$conselector.find("#rpt-con-area-2").html("");
		self.$conselector.find("#rpt-con-area-3").html("");
		self.$conselector.find("#rpt-con-area-4").html("");
		self._init_dom_();
	}).on(clickOrTap,".rptcon-ok",function(){
		var conditions = self.getCondition();
		if(conditions){
			self.options.doQuery && self.options.doQuery(conditions);
			self.$conselector.find(".rpt-barea-bg").trigger(clickOrTap);
		}
	});
}
/**
 * 打开组织机构控件
 * @param data { type:"",fbdata:"" }
 */
RptCondtions._select_org_ = function(data,_callback){
	cmp.dialog.loading(cmp.i18n("report.common.loading"));//"数据加载中.....");
	RptCondtions._load_jscss_("orgSelect",function(){
		cmp.selectOrgDestory("_select_org_");
		cmp.dialog.loading(false);
		cmp.selectOrg("_select_org_", {
			type: 2,
			minSize: -1,
			maxSize: -1,
			selectType: data.type.replace("multi",""),
			multitype: false,
			lightOptsChange: false,
			fillback: null,
			h5Header: true,
			label: ['dept', 'org', 'post', 'team', 'extP'],
			fillBackData: data.fbdata || [],
			excludeData: [],
			vj: false,
			callback: function callback(result) {
				_callback && _callback(JSON.parse(result).orgResult);
			},
			closeCallback: function closeCallback() {}
		});
	});
}
/**
 * 选择日期控件弹出
 */
RptCondtions._select_date_ = function(options,seleted){
	cmp.dialog.loading(cmp.i18n("report.common.loading"));//"数据加载中.....");
	function showSelectd(){
		cmp.dialog.loading(false);
		var datePicker = new cmp.DtPicker(options);
		datePicker.show(function(rs) {
			datePicker.dispose();
			seleted(rs.value);
		});
	}
	
	RptCondtions._load_jscss_("dtPicker",function(){
		showSelectd();
	});
}
/**
 * 改变日期类型
 */
RptCondtions._change_date_type = function(dateType,fieldComType){
	var date1 = "",
		date2 = "";
	switch (dateType) {
		case "date_fast_previousYear":
		case "date_fast_thisYear":
		case "date_fast_nextYear":
		{
			var year = parseInt(RptCondtions.formatDate(new Date(), "yyyy"));
			if(dateType == "date_fast_previousYear"){
				year = year - 1;
			}else if(dateType == "date_fast_nextYear"){
				year = year + 1;
			}
			date1 = year + "-01-01";
			date2 = year + "-12-31";
			break;
		}
		case "date_fast_previousSeason":
		case "date_fast_thisSeason":
		case "date_fast_nextSeason":
		{
			var ym = RptCondtions.formatDate(new Date(), "yyyy-MM");
			var ymArray = ym.split("-");
			var year = parseInt(ymArray[0]);
			var season = Math.floor(parseInt(ymArray[1]) / 3);
			if(ymArray[1] % 3 == 0){
				season = season -1;
			}
			if(dateType == "date_fast_previousSeason"){
				season = season -1;
				if(season == -1){
					season = 3;
					year = year -1;
				}
			}else if(dateType == "date_fast_nextSeason"){
				season = season + 1;
				if(season == 4){
					season = 0;
					year = year + 1;
				}
			}
			switch (season) {
				case 0:
					{
						date1 = year + "-01-01";
						date2 = year + "-03-31";
						break;
					}
				case 1:
					{
						date1 = year + "-04-40";
						date2 = year + "-06-30";
						break;
					}
				case 2:
					{
						date1 = year + "-07-01";
						date2 = year + "-09-30";
						break;
					}
				case 3:
					{
						date1 = year + "-10-01";
						date2 = year + "-12-31";
						break;
					}
			}
			break;
		}
		case "date_fast_previousMonth":
		case "date_fast_thisMonth":
		case "date_fast_nextMonth":
		{
			var ym = RptCondtions.formatDate(new Date(), "yyyy-MM");
			var ymArray = ym.split("-");
			var year = parseInt(ymArray[0]),month = parseInt(ymArray[1]);
			if ("date_fast_previousMonth" === dateType) {
				month = month - 1
				if(month == 0){
					month = 12;
					year = year -1;
				}
			} else if ("date_fast_nextMonth" === dateType){
				month = month + 1
				if(month == 13){
					month = 1;
					year = year + 1;
				}
			}
			date1 = year + "-" + month + "-" + 1;
			date2 = year + "-" + month + "-" + RptCondtions.getDaysOfMonth(year, month);
			break;
		}
		case "date_fast_previousWeek":
		{
			date1 = RptCondtions.getWeekdate("start", -1)
			date2 = RptCondtions.getWeekdate("end", -1)
			break;
		}
		case "date_fast_thisWeek":
		{
			date1 = RptCondtions.getWeekdate("start", 0)
			date2 = RptCondtions.getWeekdate("end", 0)
			break;
		}
		case "date_fast_nextWeek":
		{
			date1 = RptCondtions.getWeekdate("start", 1)
			date2 = RptCondtions.getWeekdate("end", 1)
			break;
		}
		case "date_fast_previousDay"://昨天
		{
			var ymd = RptCondtions.formatDate(new Date(), "yyyy-MM-dd");
			var ymdArray = ymd.split("-");
			var year = parseInt(ymdArray[0]),month = parseInt(ymdArray[1]),day = parseInt(ymdArray[2]);
			if(day == 1){
				month = month -1;
				if(month == 0){
					month = 12;
					year = year - 1;
				}
				day = "31";
			}else{
				day = day - 1;
			}
			date1 = date2 = year + "-" + month + "-" + day;
			break;
		}
		case "date_fast_thisDay":
		{
			date1 = date2 = RptCondtions.formatDate(new Date(), "yyyy-MM-dd");
			break;
		}
		case "date_fast_nextDay":
		{
			var ymd =  RptCondtions.formatDate(new Date(), "yyyy-MM-dd");
			var ymdArray = ymd.split("-");
			var year = parseInt(ymdArray[0]),month = parseInt(ymdArray[1]),day = parseInt(ymdArray[2]);
			var maxDay = RptCondtions.getDaysOfMonth(year, month);
			if(day == maxDay){
				month = month + 1;
				if(month == 13){
					month = 1;
					year = year + 1;
				}
				day = "1";
			}else{
				day = day + 1;  
			}
			date1 = date2 = year + "-" + month + "-" + day;
			break;
		}
		default:
			break;
	}
	date1 = date1.replace(/\b\d{1}\b/g,"0$&");
	date2 = date2.replace(/\b\d{1}\b/g,"0$&");
	if (fieldComType === "datetime") {
		date1 = date1 + " 00:00";
		date2 = date2 + " 23:59";
	}
	return [date1,date2];
}
/**
 * 是否为单组织机构变量
 */
RptCondtions._isSingleOrg_ = function(fieldComType){
	return fieldComType === "member"
			|| fieldComType === "account" 
			|| fieldComType === "department" 
			|| fieldComType === "post" 
			|| fieldComType === "level";
}
/**
 * 是否为多组织机构变量
 */
RptCondtions._isMultiOrg_ = function(fieldComType){
	return fieldComType === "multimember"
			|| fieldComType === "multiaccount" 
			|| fieldComType === "multidepartment" 
			|| fieldComType === "multipost" 
			|| fieldComType === "multilevel";
}
/**
 * 是否为组织机构变量
 */
RptCondtions._isOrg_ = function(fieldComType){
	return RptCondtions._isMultiOrg_(fieldComType) 
			|| RptCondtions._isSingleOrg_(fieldComType);
}
/**
 * 获取月份的天数
 * @param year
 * @param month
 * @returns {number}
 */
RptCondtions.getDaysOfMonth = function (year, month) {
	var days = 30;
	switch (month) {
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12:
			days = 31;
			break;
		case 2:
			{
				if (year % 4 === 0) {
					days = 28;
				} else {
					days = 29;
				}
			}
			break;
		case 4:
		case 6:
		case 9:
		case 11:
			days = 30;
			break;
	}
	return days;
}
/**
 * 获取周的开始或者结束时间
 * type[start|end] //
 * dates[-1|0|1] //上周、本周、下周
 */
RptCondtions.getWeekdate = function (type, dates) {
	var now = new Date();
	var nowTime = now.getTime();
	var day = now.getDay();
	var longTime = 24 * 60 * 60 * 1000;
	var n = longTime * 7 * (dates || 0);
	if (type == "start") {
		var dd = nowTime - (day - 1) * longTime + n;
	};
	if (type == "end") {
		var dd = nowTime + (7 - day) * longTime + n;
	};
	dd = new Date(dd);
	var y = dd.getFullYear();
	var m = dd.getMonth() + 1;
	var d = dd.getDate();
	m = m < 10 ? "0" + m : m;
	d = d < 10 ? "0" + d : d;
	var day = y + "-" + m + "-" + d;
	return day;
};
/**
 * 日期格式化：data.format("yyyy-MM-dd HH:mm:ss") q:季度(h也表示24小时制)
 *
 * @param fmt 日期格式
 * @returns 返回格式化后的字符串
 */
RptCondtions.formatDate = function (date, fmt) {
	var regexs = {
		"M+": date.getMonth() + 1, // 月份
		"d+": date.getDate(), // 日
		"H+": date.getHours(), // 小时
		"m+": date.getMinutes(), // 分
		"s+": date.getSeconds(), // 秒
		"q+": Math.floor((date.getMonth() + 3) / 3), // 季度
		"S": date.getMilliseconds()
		// 毫秒
	};
	// 年
	if (/(y+)/.test(fmt)) {
		fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
	}
	// 其他的格式化
	for (var k in regexs) {
		if (new RegExp("(" + k + ")").test(fmt)) {
			fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (regexs[k]) : (("00" + regexs[k]).substr(("" + regexs[k]).length)));
		}
	}
	return fmt;
};
/**
 * 将日期字符串（yyyy-MM-dd）转换为Date对象，
 *
 * @param source 字符串
 */
RptCondtions.parseDate = function (source) {
	var sdate = source.split("-");
	return new Date(sdate[0], sdate[1] - 1, sdate[2]);
}
/**
 * 将日期时间字符串（yyyy-MM-dd HH:mm:ss）转换为Date对象
 * @param source 字符串
 */
RptCondtions.parseDateTime = function (source) {
	var sdatetime = source.split(" ");
	var sdate = sdatetime[0].split("-");
	var stime = sdatetime[1].split(":");
	return new Date(sdate[0], sdate[1] - 1, sdate[2], stime[0], stime[1], stime[2]);
}
/**
 * 加载文件映射
 */
RptCondtions._load_statusMap = {
	"dtPicker":{
		"jses":[ cmpPath + "/js/cmp-picker.js" + buildversion, cmpPath + "/js/cmp-dtPicker.js" + buildversion],
		"csses":[cmpPath + "/css/cmp-picker.css" + buildversion]
	},
	"orgSelect":{
		"jses":[cmpPath + "/js/cmp-listView.js" + buildversion,cmpPath + "/js/cmp-imgCache.js" + buildversion,cmpPath + "/js/cmp-selectOrg.js" + buildversion],
		"csses":[cmpPath + "/css/cmp-listView.css" + buildversion,cmpPath + "/css/cmp-selectOrg.css" + buildversion]
	}
}
/**
 * js/css文件加载状态
 */
RptCondtions._load_status_ = {};
/**
 * 加载css、js文件
 */
RptCondtions._load_jscss_ = function(type,callback){
	var map = RptCondtions._load_statusMap[type];
	RptUtils.load_jscss( map.jses,map.csses,callback);
}
RptCondtions.tips = function(tips){
	cmp.notification.toast(tips,"center");
}
RptCondtions.alert = function(tips){
	cmp.notification.alert(tips);
}
/**
 * 打印日志
 */
RptCondtions.log = function(){
	if(console && console.log){
		for (var index = 0,lenght = arguments.length; index < lenght; index++) {
			var element = arguments[index];
			console.log(element);
		}
	}
}
RptCondtions._init_tpl_ = function(){
	var textTpl =laytpl('\
	<div class="rptcon-component rptcon-text" field-index={{d.fieldIndex}}>\
		{{# if(d.showTitle){	}}\
		<div class="rptcon-cpt-header">\
			<div class="rptcon-cpt-title">{{=d.fieldName}}</div>\
		</div>\
		{{# }					}}\
		<div class="rptcon-cpt-content">\
			<div class="rptcon-cpt-ctrl rptcon-cpt-input">\
				<div class="rptcon-cpt-input-container">\
					<input placeholder="' + cmp.i18n("report.condition.key2search") + '" type="text" value="{{=d.value }}" class="rptcon-cpt-input-value text-input">\
					<span class="rptcon-cpt-clear {{d.showX ? "" : "rptcon-hide" }}">x</span>\
					<div class="empty-mask">' + cmp.i18n("report.condition.emptyvalue") + '</div>\
				</div>\
				<span class="rptcon-cpt-circle empty-btn">' + cmp.i18n("report.condition.emptyvalue") + '</span>\
			</div>\
		</div>\
	</div>');

	var numTpl =laytpl('\
	<div class="rptcon-component rptcon-number" field-index={{d.fieldIndex}}>\
		{{# if(d.showTitle){	}}\
		<div class="rptcon-cpt-header">\
			<div class="rptcon-cpt-title">{{=d.fieldName}}</div>\
		</div>\
		{{# }					}}\
		<div class="rptcon-cpt-content">\
			<div class="rptcon-cpt-ctrl rptcon-cpt-input">\
				<div class="rptcon-cpt-input-container">\
					<input placeholder="' + cmp.i18n("report.condition.startvalue") + '" value="{{=d.value[0] }}" type="text" class="first-input rpt-num-only rptcon-cpt-input-value"/>\
					<span class="first-clear rptcon-cpt-clear {{d.value[0] !== ""  ? "" : "rptcon-hide" }}">x</span>\
					<div class="empty-mask">' + cmp.i18n("report.condition.emptyvalue") + '</div>\
				</div>\
				<span class="rptcon-cpt-connect">-</span>\
				<div class="rptcon-cpt-input-container">\
					<input placeholder="' + cmp.i18n("report.condition.endvalue") + '"  value="{{=d.value[1] }}"   type="text"  class="second-input rpt-num-only rptcon-cpt-input-value"/>\
					<span class="second-clear rptcon-cpt-clear {{d.value[1] !== ""  ? "" : "rptcon-hide" }}">x</span>\
					<div class="empty-mask">' + cmp.i18n("report.condition.emptyvalue") + '</div>\
				</div>\
				<span class="rptcon-cpt-circle empty-btn">' + cmp.i18n("report.condition.emptyvalue") + '</span>\
			</div>\
		</div>\
	</div>');
	var dateTpl =laytpl('\
	<div class="rptcon-component rptcon-datetime" field-index={{d.fieldIndex}}>\
		{{# if(d.showTitle){	}}\
		<div class="rptcon-cpt-header closed">\
			<div class="rptcon-cpt-title">{{=d.fieldName}}</div>\
			<span class="cmp-icon cmp-icon-arrowdown"></span>\
			<span class="cmp-icon cmp-icon-arrowup"></span>\
		</div>\
		{{# }					}}\
		<div class="rptcon-cpt-content">\
			<div class="rptcon-cpt-ctrl rptcon-cpt-input">\
				<div class="first-container rptcon-cpt-input-container">\
					<input readonly="readonly" placeholder="' + cmp.i18n("report.condition.startdate") + '" value="{{=d.value[0] }}"  class="first-input rptcon-cpt-input-value" type="text" />\
					<span class="first-clear rptcon-cpt-clear {{d.value[0] !== ""  ? "" : "rptcon-hide" }}">x</span>\
					<div class="empty-mask">' + cmp.i18n("report.condition.emptyvalue") + '</div>\
				</div>\
				<span class="rptcon-cpt-connect cap-icon-jianhao">-</span>\
				<div class="second-container rptcon-cpt-input-container">\
					<input readonly="readonly"  placeholder="' + cmp.i18n("report.condition.enddate") + '" value="{{=d.value[1] }}"  class="second-input rptcon-cpt-input-value" type="text" />\
					<span class="second-clear rptcon-cpt-clear {{d.value[1] !== "" ? "" : "rptcon-hide" }}">x</span>\
					<div class="empty-mask">' + cmp.i18n("report.condition.emptyvalue") + '</div>\
				</div>\
			</div>\
			<div class="rptcon-cpt-ctrl rptcon-cpt-tag">\
				<div class="rptcon-cpt-items {{d.showTitle ? "rptcon-limit-h" : "" }} ">\
					<div class="rptcon-cpt-item" date-type="empty">' + cmp.i18n("report.condition.emptyvalue") + '</div>\
					<div class="rptcon-cpt-item {{d.defaultSelected == "date_fast_previousYear" ? "item-selected":"" }}" date-type="date_fast_previousYear">' + cmp.i18n("report.condition.date.date_fast_previousYear") + '</div>\
					<div class="rptcon-cpt-item {{d.defaultSelected == "date_fast_thisYear" ? "item-selected":"" }}" date-type="date_fast_thisYear">' + cmp.i18n("report.condition.date.date_fast_thisYear") + '</div>\
					<div class="rptcon-cpt-item {{d.defaultSelected == "date_fast_nextYear" ? "item-selected":"" }}" date-type="date_fast_nextYear">' + cmp.i18n("report.condition.date.date_fast_nextYear") + '</div>\
					<div class="rptcon-cpt-item {{d.defaultSelected == "date_fast_previousSeason" ? "item-selected":"" }}" date-type="date_fast_previousSeason">' + cmp.i18n("report.condition.date.date_fast_previousSeason") + '</div>\
					<div class="rptcon-cpt-item {{d.defaultSelected == "date_fast_thisSeason" ? "item-selected":"" }}" date-type="date_fast_thisSeason">' + cmp.i18n("report.condition.date.date_fast_thisSeason") + '</div>\
					<div class="rptcon-cpt-item {{d.defaultSelected == "date_fast_nextSeason" ? "item-selected":"" }}" date-type="date_fast_nextSeason">' + cmp.i18n("report.condition.date.date_fast_nextSeason") + '</div>\
					<div class="rptcon-cpt-item {{d.defaultSelected == "date_fast_previousMonth" ? "item-selected":"" }}" date-type="date_fast_previousMonth">' + cmp.i18n("report.condition.date.date_fast_previousMonth") + '</div>\
					<div class="rptcon-cpt-item {{d.defaultSelected == "date_fast_thisMonth" ? "item-selected":"" }}" date-type="date_fast_thisMonth">' + cmp.i18n("report.condition.date.date_fast_thisMonth") + '</div>\
					<div class="rptcon-cpt-item {{d.defaultSelected == "date_fast_nextMonth" ? "item-selected":"" }}" date-type="date_fast_nextMonth">' + cmp.i18n("report.condition.date.date_fast_nextMonth") + '</div>\
					<div class="rptcon-cpt-item {{d.defaultSelected == "date_fast_previousWeek" ? "item-selected":"" }}" date-type="date_fast_previousWeek">' + cmp.i18n("report.condition.date.date_fast_previousWeek") + '</div>\
					<div class="rptcon-cpt-item {{d.defaultSelected == "date_fast_thisWeek" ? "item-selected":"" }}" date-type="date_fast_thisWeek">' + cmp.i18n("report.condition.date.date_fast_thisWeek") + '</div>\
					<div class="rptcon-cpt-item {{d.defaultSelected == "date_fast_nextWeek" ? "item-selected":"" }}" date-type="date_fast_nextWeek">' + cmp.i18n("report.condition.date.date_fast_nextWeek") + '</div>\
					<div class="rptcon-cpt-item {{d.defaultSelected == "date_fast_previousDay" ? "item-selected":"" }}" date-type="date_fast_previousDay">' + cmp.i18n("report.condition.date.date_fast_previousDay") + '</div>\
					<div class="rptcon-cpt-item {{d.defaultSelected == "date_fast_thisDay" ? "item-selected":"" }}" date-type="date_fast_thisDay">' + cmp.i18n("report.condition.date.date_fast_thisDay") + '</div>\
					<div class="rptcon-cpt-item {{d.defaultSelected == "date_fast_nextDay" ? "item-selected":"" }}" date-type="date_fast_nextDay">' + cmp.i18n("report.condition.date.date_fast_nextDay") + '</div>\
				</div>\
			</div>\
		</div>\
	</div>');
	var orgTpl =laytpl('\
	<div class="rptcon-component rptcon-org" field-index={{d.fieldIndex}}>\
		{{# if(d.showTitle){	}}\
		<div class="rptcon-cpt-header">\
			<div class="rptcon-cpt-title">{{=d.fieldName}}</div>\
		</div>\
		{{# }					}}\
		<div class="rptcon-cpt-content">\
			<div class="rptcon-cpt-ctrl rptcon-cpt-input">\
				<div class="rptcon-cpt-input-container">\
					<input placeholder="' + cmp.i18n("report.condition.select") + '" value="{{=d.value}}" readonly="readonly" class="rptcon-cpt-input-value">\
					<span class="clear rptcon-cpt-clear {{d.showX ? "" : "rptcon-hide" }}">x</span>\
					<span class="arrow rptcon-cpt-arrow {{d.showX ? "rptcon-hide" : "" }}">&gt;</span>\
					<div class="empty-mask">' + cmp.i18n("report.condition.emptyvalue") + '</div>\
				</div>\
				<span class="rptcon-cpt-circle empty-btn">' + cmp.i18n("report.condition.emptyvalue") + '</span>\
			</div>\
		</div>\
	</div>');
	var enumTpl =laytpl('\
	<div class="rptcon-component rptcon-select" field-index={{d.fieldIndex}}>\
		{{# if(d.showTitle){	}}\
		<div class="rptcon-cpt-header closed">\
		<div class="rptcon-cpt-title">{{=d.fieldName}}</div>\
		{{# if(d.showTitle && d.enumItems.length > 5){	}}\
		<span class="cmp-icon cmp-icon-arrowdown"></span>\
		<span class="cmp-icon cmp-icon-arrowup"></span>\
		{{# }					}}\
		</div>\
		{{# }					}}\
		<div class="rptcon-cpt-content">\
		<div class="rptcon-cpt-items {{(d.showTitle && d.enumItems.length > 5)? "rptcon-limit-h" : ""}}">\
			{{# if(d.useEmpty){	}}\
				<div class="rptcon-cpt-item {{d.defEmpty ? "item-selected" : ""}}" enum-index="empty">' + cmp.i18n("report.condition.emptyvalue") + '</div>\
			{{# }			}}\
			{{# var selectedIndex = 0;\
				for(var i = 0,leng = d.enumItems.length; i < leng; i++){\
					var enumItem = d.enumItems[i];\
					var clazz = "";\
					if(d.selectedItem[selectedIndex] === i){\
						clazz = "item-selected";\
						selectedIndex++;\
					}\
			}}\
				<div class="rptcon-cpt-item {{=clazz }}" enum-index="{{i}}">{{=enumItem.name}}</div>\
			{{# }			}}\
			</div>\
		</div>\
	</div>');
	RptCondtions.tpls = {
		"textTpl":textTpl,
		"dateTpl":dateTpl,
		"orgTpl":orgTpl,
		"enumTpl":enumTpl,
		"numTpl":numTpl
	};
}
